package org.balthie.demo.jdk.nio.reactor.multiplyThread;

import java.nio.channels.SelectionKey;

public class Processer implements Runnable {
	private SelectionKey selectionKey ;
	int state = MthreadHandler.READING;

	public Processer(SelectionKey selectionKey) {
		this.selectionKey = selectionKey;
	}

	synchronized void processAndHandOff() {
		process();
		state = MthreadHandler.SENDING;
		// or rebind attachment
		// process完,开始等待write就绪
		this.selectionKey.interestOps(SelectionKey.OP_WRITE);
	}

	void process() {
		/* ... */
		return;
	}

	public void run() {
		processAndHandOff();
	}
}
